package cn.cxyxj.code_auth_jwt_persistence_prod.handler;

import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author cxyxj
 */
@RestControllerAdvice
public class ExceptionHandlerAdvice {

    @ExceptionHandler(OAuth2Exception.class)
    public String oAuth2Exception(OAuth2Exception exception){
        String message = exception.getMessage();
        return message;
    }

    @ExceptionHandler(RuntimeException.class)
    public String runtimeException(RuntimeException exception){
        String message = exception.getMessage();
        return message;
    }
}
